<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>精细化节点流转情况日报</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<script src="../scripts/boot.js" type="text/javascript"></script>
</head>

<body>

<style type="text/css">
	* { padding:0px margin:0px; }
	.wxftitle { width:100%; padding:10px 0px 20px 0px; font-weight:bold; text-align:center; font-size:22px; }
	.wxftitle span{cursor: pointer;}
	.wxftable { width:96%; margin:0px auto; border-collapse:collapse; }
	.wxftable td { padding:10px; border:1px solid #d2d2d2; text-align:center; font-size:15px; line-height:24px; color:#2c2c2c; }
	.wxftable .firstTr { background-color:#E5EDF3; }
	.wxfload td { width:100%; height:300px; line-height:300px; text-align:center; font-size:24px; font-weight:bold; color:#747474; border:none; }

	.wxftable td.wxftd1 { text-align:left; }
	.wxftable td.wxftd1 font { color:#1491ff; padding-right:6px; }
	.wxftable td.wxftd2 font { color:#1491ff; padding:0px 5px; }
	.wxftable td.wxftd2 span { color:#1491ff; padding-left:5px; }
</style>

<div id="wxftitle" class="wxftitle"></div>
<table id="wxftable" class="wxftable">
	<tr class="wxfload"><td>数据生成中...</td></tr>
</table>

</body>

<script type="text/javascript">
	var basepath = window.location.pathname + "/../";
	let dailyDate = '${dailyDate}';

	function search(){
		mini.open({
			url : basepath+"moveSearch",
			title : "选择日期",
			width : 500,
			height : 500,
			allowResize : false,
			ondestroy : function (action) {
				if(action == "search"){
					var iframe = this.getIFrameEl();
					var data = iframe.contentWindow.GetData();
					data = mini.clone(data);
					data.dailyDate = mini.formatDate(data.dailyDate, "yyyy-MM-dd");
					console.log(data);
					window.location.href = "moveDaily?dailyDate="+data.dailyDate ;
				}
			}
		});
	}

	$.ajax({
		url: "moveDailyData?dailyDate="+dailyDate,
		type: "post",
		dataType: "json",
		cache: false,
		success: function(resultBean){
			if(!resultBean.res){
				mini.alert(resultBean.msg);
				return;
			}
			data = resultBean.data;
			// 设置标题
			$("#wxftitle").html(data.title);

			// 设置表格内容
			var tableStr = '<tr class="firstTr"><td width="7%">员额法官</td><td width="7%">流转节点数</td><td width="7%">涉及案件数</td><td>案件名称</td><td width="20%">流转节点</td><td width="7%">处理天数</td><td width="7%">是否逾期</td></tr>';

			var personList = data.content;
			for(var i=0; i<personList.length; i++) {

				var caseList = personList[i].detail;

				// 计算总行数
				var sumNode = 0;
				for(var j=0; j<caseList.length; j++) {
					sumNode = sumNode + caseList[j].nodelList.length;
				}

				var personRowSpanFlag = true;
				if(sumNode > 0) {
					for(var j=0; j<caseList.length; j++) {

						var nodeList = caseList[j].nodelList;
						for(var a=0; a<nodeList.length; a++) {

							if(personRowSpanFlag) {
								tableStr += '<tr>';
								tableStr += '<td rowspan="' + sumNode + '">' + personList[i].name + '</td>';
								tableStr += '<td rowspan="' + sumNode + '">' + personList[i].sumNode + '</td>';
								tableStr += '<td rowspan="' + sumNode + '">' + personList[i].containCase + '</td>';


								if(a==0) {
									tableStr += '<td rowspan="' + nodeList.length + '" class="wxftd1"><font>' + caseList[j].caseNo + '</font>' + caseList[j].caseName + '</td>';
								}

								tableStr += '<td class="wxftd2"><font>' + nodeList[a].nodelBegin + '</font>流转至<span>' + nodeList[a].nodelEnd + '</span></td>';
								tableStr += '<td>' + nodeList[a].days + '</td>';
								tableStr += '<td>' + nodeList[a].isOver + '</td>';
								tableStr += '</tr>';
								personRowSpanFlag = false;
							} else {
								tableStr += '<tr>';

								if(a==0) {
									tableStr += '<td rowspan="' + nodeList.length + '" class="wxftd1"><font>' + caseList[j].caseNo + '</font>' + caseList[j].caseName + '</td>';
								}

								tableStr += '<td class="wxftd2"><font>' + nodeList[a].nodelBegin + '</font>流转至<span>' + nodeList[a].nodelEnd + '</span></td>';
								tableStr += '<td>' + nodeList[a].days + '</td>';
								tableStr += '<td>' + nodeList[a].isOver + '</td>';
								tableStr += '</tr>';
							}

						}

					}
				} else {
					// 今日没流转节点
					tableStr += '<tr>';
					tableStr += '<td>' + personList[i].name + '</td>';
					tableStr += '<td>' + personList[i].sumNode + '</td>';
					tableStr += '<td>' + personList[i].containCase + '</td>';
					tableStr += '<td>——</td>';
					tableStr += '<td>——</td>';
					tableStr += '<td>——</td>';
					tableStr += '<td>——</td>';
					tableStr += '</tr>';
				}

			}

			$("#wxftable").html(tableStr);


		},
		error: function(jqXHR, textStatus, errorThrown) {
			console.log(errorThrown)
			$("#wxftable").html('<tr class="wxfload"><td>数据加载失败...</td></tr>');
		}

	});

</script>

</html>